package com.jeequan.jeepay.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeequan.jeepay.core.entity.MchPayRoute;
import com.jeequan.jeepay.service.mapper.MchPayRouteMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商户支付路由 服务实现类
 * </p>
 *
 * @author [mybatis plus generator]
 * @since 2024-10-25
 */
@Service
public class MchPayRouteService extends ServiceImpl<MchPayRouteMapper, MchPayRoute> {
    public IPage<MchPayRoute> selectPage(IPage iPage, MchPayRoute mchPayRoute) {
        LambdaQueryWrapper<MchPayRoute> wrapper = MchPayRoute.gw();
        if (StringUtils.isNotEmpty(mchPayRoute.getAppId())) {
            wrapper.eq(MchPayRoute::getAppId, mchPayRoute.getAppId());
        }
        if (StringUtils.isNotEmpty(mchPayRoute.getWayCode())) {
            wrapper.eq(MchPayRoute::getWayCode, mchPayRoute.getWayCode());
        }
        if (mchPayRoute.getState() != null) {
            wrapper.eq(MchPayRoute::getState, mchPayRoute.getState());
        }
        wrapper.orderByDesc(MchPayRoute::getCreatedAt);
        IPage<MchPayRoute> pages = this.page(iPage, wrapper);
        return pages;
    }
}
